using Max.PH4_2104A.Shopping.ThreeFrame.BLL;
using Max.PH4_2104A.Shopping.ThreeFrame.DAL;
using Microsoft.EntityFrameworkCore;

var builder = WebApplication.CreateBuilder(args);

// Add services to the container.

builder.Services.AddControllers();
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen(x =>
{
    x.IncludeXmlComments(@"obj\Debug\net6.0\Max.PH4_2104A.Shopping.ThreeFrame.API.xml");
});


builder.Services.AddDbContext<MyDbContext>(x =>
{
    x.UseSqlServer(builder.Configuration.GetConnectionString("SqlServerConnection"));
});

builder.Services.AddTransient<SystemUserDAL>();
builder.Services.AddTransient<SystemUserBLL>();


var app = builder.Build();

// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
    app.UseSwagger();
    app.UseSwaggerUI();
}


app.UseCors(x =>
{
    x.AllowAnyHeader().AllowCredentials().AllowAnyMethod().SetIsOriginAllowed(_ => true);
});

app.UseAuthorization();

app.MapControllers();

app.Run();
